package yf.mall.service;

import org.springframework.transaction.annotation.Transactional;
import yf.mall.entity.AccountEntity;
import yf.mall.entity.AccountRecordEntity;
import com.yf.service.BaseService;
import yf.mall.entity.MallOrderEntity;
import yf.mall.vo.AccountRecordVo;
import yf.mall.vo.OrderItemVo;

import java.io.InputStream;
import java.math.BigDecimal;
import java.util.List;

/**
 * 账户Service接口
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Mon Aug 26 16:58:11 CST 2019
 */
public interface AccountService extends BaseService<AccountEntity> {
    /**api**/
    /**
     * 转账业务
     *
     * @param fromUserId
     * @param toUserId
     * @param amount
     * @param remark
     */
    void transfer(Long fromUserId, Long toUserId, int type, BigDecimal amount, String remark);


    /**
     * 支付
     * @param userId
     * @param type
     * @param amount
     * @param orderNo
     */
    void pay(Long userId,int type,BigDecimal amount,String orderNo);


    /**
     * 自动支付
     * @param userId
     * @param type
     * @param amount
     * @param orderNo
     */
    void autoPay(Long userId,int type,BigDecimal amount,String orderNo);

    /**
     * 奖励经验值
     * @param userId
     * @param amount
     * @param OrderNO
     * @param name
     */
    void rewardExp(Long userId,BigDecimal amount,String orderNo,String name,boolean reward);

    /**
     * 奖励给平级
     * @param userId
     * @param amount
     * @param orderNo
     * @param name
     * @param reward
     */
    void rewardEqlExp(Long userId,BigDecimal amount,String orderNo,String name,boolean reward);

    /**
     * 追回经验值
     * @param orderEntity
     */
    void backExp(Long userId,BigDecimal amount,String orderNo,String name);

    /**
     * 手动转经验值
     * @param fromUserId
     * @param toUserId
     * @param amount
     * @param remark
     */
//    void transferExp(Long fromUserId,Long toUserId,BigDecimal amount,String remark);

    /**
     * 奖励
     * 用于各种奖励的条件
     * @param userId
     * @param type
     * @param amount
     * @param name
     * @param orderNo
     * @param isReward
     */
    void reward(Long userId,int type, BigDecimal amount,String name,String orderNo,Boolean isReward,Integer busType);

    /**
     * 新用户注册奖励100元优惠券
     * 给上级送20元优惠券
     * @param userId
     */
    void rewardRegister(Long userId);

    /**
     * 给予店铺利润
     * @param shopId
     * @param money
     * @param name
     * @param orderNo
     */
    void shopProfit(Long shopId,BigDecimal money,String name,String orderNo);

    /**
     * 店铺管理利润
     * @param shopId
     * @param money
     * @param name
     * @param orderNo
     */
    void shopManager(Long shopId,BigDecimal money,String name,String orderNo);

    /**
     * 取消订单的一些列操作
     * @param orderNo
     */
    void cancel(String orderNo);

    //退回
//    void returnBack(Long userId,int type,BigDecimal amount,String orderNo);


    /**back**/
    //后台转账
    void transfer(AccountRecordVo recordVo);

    /**common*/
    //增加账户
    AccountEntity increase(Long userId, Integer type, BigDecimal amount);
    //减少账户
    AccountEntity decrease(Long userId,Integer type,BigDecimal amount);


    //找出用户的所有账户
    List<AccountEntity> findByUserId(Long userId);

    //收款
    AccountRecordEntity payment(Long userId,Long recordId);

    //充值订单提交
    String commit(Long userId, BigDecimal amount, String noticeUrl);

    //微信回调充值
    void recharge(String orderNo,Integer amount);

    //找到某人的某个账户  没有就生成
    AccountEntity findByUserIdAndType(Long userId,Integer type);


    List<OrderItemVo> findCommission(Long userId, Integer year, Integer month);



    void doneTransfer(String orderNo);

    void doneTransfer(AccountRecordEntity accountRecordEntity);

    List<AccountRecordEntity> findByOrderNoAndBusType(String orderNo,Integer ...busType);

    //五集注册奖励89元优惠券
    void rewardWgRegister(Long userId);

    void upload(InputStream inputStream);
}
